"""关注模型"""
from sqlalchemy import Column, Integer, ForeignKey, UniqueConstraint
from .base import BaseModel


class Follow(BaseModel):
    """关注表模型"""
    __tablename__ = "follows"
    
    follower_id = Column(Integer, ForeignKey("users.id"), nullable=False)  # 关注者ID
    following_id = Column(Integer, ForeignKey("users.id"), nullable=False)  # 被关注者ID
    
    # 确保用户对另一用户只能关注一次
    __table_args__ = (
        UniqueConstraint('follower_id', 'following_id', name='_follower_following_uc'),
    )
